package summary;

/**
 * @Author: 海琳琦
 * @Date: 2022/8/30 11:47
 */
public class Title303 {

    /**
     * i,前缀和
     */
    private int pre[];

    public Title303(int[] nums) {
        int n = nums.length;
        int sum = 0;
        pre = new int[n + 1];
        for (int i = 0; i < n; i++) {
            //初始化前缀和
            pre[i] = sum;
            sum += nums[i];
        }
        pre[n] = sum;
    }

    public int sumRange(int left, int right) {
        return pre[right + 1] - pre[left];
    }

    public static void main(String[] args) {

    }
}
